import java.util.Scanner;

//返回字符创中第一次出现的字母的下标
public class Test1 {
    public static int func(String s){
        char[] chars = new char[30];
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            chars[ch-97]++;
        }
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if(chars[ch-97] == 1){
                return i;
            }
        }
        return -1;
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = new String(scanner.nextLine());
        System.out.println(func(s));
    }
}
